home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / whoapc.zip / WHOA!.ASM < prev    next >
Assembly Source File  |  1988-08-25  |  33KB  |  1,159 lines

  1. ;Name            WHOA
  2. ;Title            WHOA! Version 1.0 - Brad D Crandall, 1987
  3. ;            All rights reserved.
  4. ;------------------------------------------------------------------------------
  5. ;    WHOA!.asm    -    Brad D Crandall
  6. ;                
  7. ;
  8. ;    This program will slow a computer down so programs and
  9. ;    games can be examined closely. Designed to run in a Text
  10. ;    or graphic screen mode. To bring up WHOA!'s Menu,
  11. ;    press <Alt> <F10>.
  12. ;
  13. ;    Compiler:    MASM Version 2.0 or greater.
  14. ;    Computer:    IBM PC or Compatible running on MS-DOS or
  15. ;            PC-DOS Version 2.0 or greater. Also works
  16. ;            on IBM's Personal System/2s under DOS 3.3.
  17. ;
  18. ;    Compiling procedure:
  19. ;            masm WHOA!;
  20. ;            link WHOA!;
  21. ;            exe2bin WHOA! WHOA!.com
  22. ;
  23. ;    Notes:
  24. ;        Care should be taken when determining what value to use for
  25. ;        SET_MAX (located in EQUATE AREA). If the value is too large,  
  26. ;        a hard loop may result. The value 435 if optimum for a 12-MHz
  27. ;        machine. Slower machines will need a slightly lower value.
  28. ;
  29. ;        Special consideration has been taken to allow WHOA to be 
  30. ;        compatible with DOS versions earlier than 3.1, which do not
  31. ;        support the MULTIPLEX interrupt protocol.  WHOA uses the 
  32. ;        multiplex interrupt because it provides a broader range of 
  33. ;        software compatibility than do the eight conventional user 
  34. ;        interrupts.
  35. ;
  36. ;        For older versions of DOS, WHOA uses a user interrupt
  37. ;        (SLOW_INT) as the channel of communication to the resident
  38. ;        portion of WHAO!. To provide full compatibility, SLOW_INT
  39. ;        should be set to an interrupt that is not used by any of the 
  40. ;        software you wish to use WHOA with.
  41. ;
  42. ;------------------------------------------------------------------------------
  43.  
  44. ;------------------------------------------------------------------------------
  45. ;                E Q U A T E   A R E A
  46. ;------------------------------------------------------------------------------
  47. MULTI_INT        equ    2fh    ; Multiplex used if DOS >= 3.1.
  48. SLOW_INT        equ    60h    ; Interrupt used if DOS < 3.1,
  49.                     ; other possible values 60h-67h.
  50. KEYBOARD_INT        equ    16h    ; Keyboard Interrupt.
  51. TIME_INT        equ    08h    ; Time of Day Interrupt.
  52. MULTI_HANDLE        equ    89h    ; Our Unique Multiplex ID.
  53. INSTALL_CHECK        equ    0h    ; Code to check if resident.
  54. UNINSTALL        equ    1h    ; Code to uninstall WHOA!
  55. SET_LOOP        equ    2h    ; Code to set the delay loop.
  56.  
  57. STACK_SIZE        equ    100h    ; Size for our Stack.
  58.  
  59. HOT_KEY            equ    7100h    ; ALT F10.
  60. STROBE_PAUSE        equ    5    ; Strobe delay count setting.
  61. SET_MIN            equ    1    ; Minimum delay loop value.
  62. SET_MAX            equ    435    ; Maximum delay loop value.
  63. TIME_PAUSE        equ    100    ; Inner loop initial setting.
  64. LOOP_DEFAULT        equ    350    ; Delay default setting.
  65.  
  66. STROBE_BEGIN        equ    28    ; Column coordinate for strobe.
  67. STROBE_END        equ    37    ; Column coordinate for strobe.
  68.  
  69. SCREEN_SIZE        equ    16 * 1024 / 2 ; Size in words of largest
  70.                     ; screen to save.
  71.  
  72. BORDER            =    16+14    ; Border color.
  73. TEXT            =    16+15    ; Text color.
  74.  
  75. DOS_CMP            equ    0310h    ; DOS comparison constant.
  76.  
  77.             ;--- Return Codes ---
  78. NOT_INSTALLED        equ    0    ; WHOA not installed return code.
  79. INSTALLED        equ    0ffh    ; WHOA is installed return code.
  80. ERROR            equ    0feh    ; Error occurred
  81. OK            equ    0fdh    ; No errors occurred.
  82.  
  83. ;------------------------------------------------------------------------------
  84. ;                 M A C R O   A R E A
  85. ;------------------------------------------------------------------------------
  86.  
  87.             ;----------------------------------------------------
  88.             ;    DISPLAY_AT parm1,parm2,parm3,parm4 - Display
  89.             ;    message on screen starting at fixed 
  90.             ;    location. Does not use DOS.
  91.             ;
  92.             ;    parm1 = X coordinate of start of message.
  93.             ;    parm2 = Y coordinate of start of message.
  94.             ;    parm3 = Color of message.
  95.             ;    parm4 = String of character to display.
  96.             ;----------------------------------------------------
  97. DISPLAY_AT        macro    parm1,parm2,parm3,parm4
  98.             local    label1,label2
  99.             jmp    label2
  100. label1            db    parm4&,0
  101. label2:            mov    si,offset cseg:label1
  102.             mov    cx,&parm3
  103.             mov    ax,&parm2
  104.             mov    di,&parm1
  105.             call    display_at_proc
  106.             endm
  107.  
  108.             ;---------------------------------------------------
  109.             ;    DISPLAY_DOS parm1 - Display a message to the
  110.             ;    console. Uses DOS function 09h.
  111.             ;
  112.             ;    parm1 = Message to display.
  113.             ;---------------------------------------------------
  114. DISPLAY_DOS        macro    parm1
  115.             local    label1,label2
  116.             jmp    label2
  117. label1            db    parm1&,24h
  118. label2:            mov    dx,offset cseg:label1
  119.             mov    ah,09h
  120.             int    21h
  121.             endm
  122.  
  123.             ;-----------------------------------------------------
  124.             ;    RESIDENT parm1 - Executes the resident portion
  125.             ;    of WHOA! Determines which interrupt to 
  126.             ;    use (multiplex or user) based on DOS version.
  127.             ;
  128.             ;    parm1 - Resident function.
  129.             ;-----------------------------------------------------
  130. RESIDENT        macro    parm1
  131.             local    label1,label2
  132.             mov    al,&parm1
  133.             cmp    cs:dos_version,DOS_CMP    ; What DOS Version??
  134.             jae    label1            ; Jump if DOS >= 3.1.
  135.             call    call_interrupt
  136.             jmp    label2
  137. label1:            mov    ah,MULTI_HANDLE
  138.             int    MULTI_INT
  139. label2:
  140.             endm
  141.  
  142. ;------------------------------------------------------------------------------
  143. ;                C O D E   A R E A
  144. ;------------------------------------------------------------------------------
  145. cseg            segment    byte public 'code'
  146.             assume    cs:cseg,ds:cseg
  147.             org    100h
  148. slowdown        proc    far
  149.             jmp    slowdown_0010
  150.  
  151. ;------------------------------------------------------------------------------
  152. ;                T S R   D A T A   A R E A
  153. ;------------------------------------------------------------------------------
  154. dos_version        dw    ?    ; Version number of DOS.
  155. slow_interrupt        db    SLOW_INT ; Interrupt used if DOS < 3.1.
  156. old_multi_int        dd    ?    ; Address of old multiplex.
  157. old_keyboard_int    dd    ?    ; Address of old keyboard.
  158. old_time_int        dd    ?    ; Address of old time of day.
  159. activated        db    0    ; Switch to prevent re-entry.
  160. crt_stat        dw    ?    ; CRT port.
  161.  
  162. save_sp            dw    ?    ; Save area of old stack.
  163. save_ss            dw    ?    ; Save area of old stack.
  164. video_state        db    ?    ; Save video state.
  165. cursor_location        dw    ?    ; Save cursor location.
  166. current_page        db    ?    ; Save page.
  167. current_background    db    ?    ; Current background color.
  168. current_palette        db    ?
  169.  
  170. asc_value        db    6 dup(0) ; Area for number display.
  171. setting            dw    LOOP_DEFAULT ; Delay loop setting.
  172. delay_switch        db    1    ; Delay Switch on/off. 1 = ON.
  173.  
  174. strobe            dw    STROBE_BEGIN ; Location of strobe pattern.
  175. move_strobe1        dw    ?    ; Delay countdown.
  176. move_strobe2        dw    ?    ; Delay countdown.
  177. screen_seg        dw    ?    ; Address of screen.
  178. enable            db    1    ; Enable/disable switch.
  179. columns            db    80    ; Number of columns on screen.
  180.  
  181. ;------------------------------------------------------------------------------
  182. ;               T S R   C O D E   A R E A
  183. ;------------------------------------------------------------------------------
  184.  
  185.             ;-------------------------------------------------------
  186.             ;   multiplex - This procedure handles external
  187.             ;    communications for the memory resident
  188.             ;    portion of WHOA running on DOS 3.1 or 
  189.             ;    greater.
  190.             ;-------------------------------------------------------
  191. multiplex        proc    far
  192.  
  193.             ;--- Check for our unique handle. If not found ---
  194.             ;--- jump to next multiplex routine in chain. ----
  195.  
  196.             cmp    ah,MULTI_HANDLE 
  197.             je    multiplex_0010  
  198.             jmp    dword ptr cs:old_multi_int
  199. multiplex_0010:        call    request     
  200.             iret    ; Must return as an interrupt routine.
  201. multiplex        endp
  202.  
  203.             ;-------------------------------------------------
  204.             ;   interrupt - This procedure handles external
  205.             ;    communications for the memory resident
  206.             ;    portion of WHOA running on DOS 3.0 or
  207.             ;    less.
  208.             ;-------------------------------------------------
  209. interrupt        proc    far
  210.             call    request
  211.             iret
  212. interrupt        endp
  213.  
  214.             ;-----------------------------------------------
  215.             ;   request - This routine execute a slowdown
  216.             ;    function based on the contents of AL. 
  217.             ;
  218.             ;   Status returned in AL.
  219.             ;-----------------------------------------------
  220. request            proc    near
  221.             ;--- We are being called. Find out why ---
  222.  
  223. request_0010:        cmp    al,INSTALL_CHECK ; Check for installed?
  224.             jne    request_0020    ; Jump if NO.   
  225.             mov    al,INSTALLED    ; We are already installed.
  226.             ret
  227.  
  228. request_0020:        cmp    al,UNINSTALL